$(function () {
  $(".login-block > a").click(function () {
    $(".login-block > a").removeClass("border");
    $(this).addClass("border");
  });
  let hover = $(".hover");
  let a = $(".login-block > a");
  for (let i = 0; i < a.length; i++) {
    a[i].onclick = function () {
      let j = Math.abs(i - 1);
      hover[j].setAttribute("id", "");

      hover[i].setAttribute("id", "block");
    };
  }

  $(".btn").click(function () {
    let value1 = $(".value")[0].value;
    let value2 = $(".value")[1].value;
    console.log(value1);
    $.ajax({
      url: "http://jx.xuzhixiang.top/ap/api/login.php",
      type: "get",
      data: { username: value1, password: value2 },
      success: function (res) {
        if (res.code == 1) {
          location.href = "../index.html";
        } else {
          alert("用户名密码错误");
        }
      },
    });
  });
});
